#!/usr/bin/perl

use DBI;
#连接数据库
$dbdrive="mysql";
$dbname="xt";
$dbuser="mail";
$dbpass="3611";
$dbh=DBI->connect("DBI:$dbdrive:$dbname:166.111.111.111:3306",$dbuser,$dbpass);

#open(TMP,"pop3user_4568.txt");
open(TMP,"test");
@userlist=<TMP>;
close(TMP);
chomp(@userlist);

foreach $user(@userlist) {
        chomp($user);
        $sql="select access_time from tl_pop where login_name='$user' order by access_time desc limit 1;";
        $sth=$dbh->prepare($sql);
        $sth->execute();
                while($id=$sth->fetchrow()){
                print "$user , $id\n";
                }
}
